package decorator;

/**
 * @author ycc
 * @date 2024/4/2
 * 使用装饰者模式为Espresso对象添加了不同的调料（Milk和Mocha），而不需要修改Espresso类的代码。
 * 这样，我们可以轻松地为现有的对象添加新功能，同时保持代码的可扩展性和可维护性。
 */
public class DecoratorPatternDemo {
    public static void main(String[] args) {
        Beverage espresso = new Espresso();
        System.out.println("Espresso cost: " + espresso.cost());

        Beverage espressoWithMilk = new Milk(espresso);
        System.out.println("Espresso with Milk cost: " + espressoWithMilk.cost());

        Beverage espressoWithMilkAndMocha = new Mocha(new Milk(espresso));
        System.out.println("Espresso with Milk and Mocha cost: " + espressoWithMilkAndMocha.cost());
    }
}
